// pages/venue/venuedetil/venuedetill.js
const WxParse = require('../../../wxParse/wxParse.js');
const imageCdn = 'https://tdesign.gtimg.com/mobile/demos';
const swiperList = [
  `/images/jianshenguan.png`,
  `/images/my_unactive.png`,
  `${imageCdn}/swiper1.png`,
  `${imageCdn}/swiper2.png`,
  `${imageCdn}/swiper1.png`,
];
Page({
    /**
     * 页面的初始数据
     */
    data: {
      phone:'',
      gymIntro:'',
      location:'',
      gymid:'',
      pictures:[],
      // 评价星星
      value: [3, 3, 0],
      texts: ['1分', '2分', '3分', '4分', '5分'],
      // 头部轮播图
      current: 0,
    autoplay: true,
    duration: 500,
    interval: 3000,
    swiperList
    },
    
   // 返回上一页
   onNavigate(){
    wx.navigateBack({
      delta: 1
    })
  },
      onTap(e) {
        const { index } = e.detail;
        console.log(index);
      },
      onChange(e) {
        const { current, source } = e.detail;
        console.log(current, source);
      },
      onImageLoad(e) {
        console.log(e.detail.index);
      },
  
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      this.setData({
        gymid: options.gymid
      })
      wx.request({
        url: 'http://localhost:8080/keep/gym/gymid/key',
        data: {
          gymid: this.data.gymid
        },
        method: "GET",
        header: {
          'Authorization': getApp().globalData.authorization
        },
        success: (resp) => {
          WxParse.wxParse('ww', 'html', resp.data.gymIntro, this, 0);
          this.setData({
            swiperList:resp.data.picture.split(','),
            phone:resp.data.phone,
            location:resp.data.location,
          })
        },
        fail: resp => {
          console.log("失败")
        },
      })


    },

  
    goBooking: function(event) {
      var gymId = this.data.gymid.match(/\d+/)[0];
     console.log(gymId)
      wx.switchTab({
        url: '/pages/reservation/reservation?gymId='+gymId,
      });
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})